package day6.problem1;

import java.util.*;

//高精度加法
//https://www.nowcoder.com/practice/11ae12e8c6fe48f883cad618c2e81475?tpId=196&tqId=37176&ru=/exam/oj


public class Solution {
    public String solve (String s, String t) {
        s = new StringBuffer(s).reverse().toString();
        t = new StringBuffer(t).reverse().toString();
        int n = s.length(), m = t.length();
        int x = 0; //进制
        StringBuffer ret = new StringBuffer();
        for(int i = 0; i < n || i < m || x > 0; i++) {
            int a = i >= n ? 0 : s.charAt(i) - '0';
            int b = i >= m ? 0 : t.charAt(i) - '0';
            int k = (a + b + x) % 10;
            x = (a + b + x) / 10;
            ret.append(k);
        }
        return ret.reverse().toString();
    }
}